package com.coders.configuration;

import com.coders.info.Constants;
import com.coders.info.MusicState;
import com.coders.info.SoundState;

/**
 * This class will hold all the settings related configuration shared across
 * activities.
 * 
 * @author Subin
 * 
 */
public class SettingsConfig
{
    private static SettingsConfig settingsConfig;

    private static String         selectedLanguage         = Constants.DEFAULT_LANGUAGE.toString();
    private static String         selectedScene            = Constants.DEFAULT_SCENE.toString();
    private static String         selectedPop              = Constants.DEFAULT_POP.toString();
    private static String         selectedMusicState       = Constants.DEFAULT_MUSIC_STATE.toString();
    private static String         selectedSoundState       = Constants.DEFAULT_SOUND_STATE.toString();

    private static int            selectedLanguagePosition = 0;
    private static int            selectedScenePosition    = 0;
    private static int            selectedPopPosition      = 0;
    private static int            selectedMusicPosition    = 0;
    private static int            selectedSoundPosition    = 0;

    private static boolean        isSettingsChanged        = false;
    private static boolean        isLanguageChanged        = false;

    /**
     * Singleton enforcer
     */
    private SettingsConfig()
    {
        super();
    }

    public static SettingsConfig getInstance()
    {
        if ( null == settingsConfig )
        {
            settingsConfig = new SettingsConfig();
        }
        return settingsConfig;
    }

    public static String getSelectedLanguage()
    {
        return selectedLanguage;
    }

    public static void setSelectedLanguage( String selectedLanguage )
    {
        SettingsConfig.selectedLanguage = selectedLanguage;
        //settingsChanged();
        languageChanged();
    }

    public static String getSelectedScene()
    {
        return selectedScene;
    }

    public static void setSelectedScene( String selectedScene )
    {
        SettingsConfig.selectedScene = selectedScene;
        settingsChanged();
    }

    public static String getSelectedPop()
    {
        return selectedPop;
    }

    public static void setSelectedPop( String selectedPop )
    {
        SettingsConfig.selectedPop = selectedPop;
        languageChanged();
    }

    public static String getSelectedMusicState()
    {
        return selectedMusicState;
    }

    public static void setSelectedMusicState( String selectedMusicState )
    {
        SettingsConfig.selectedMusicState = selectedMusicState;
        settingsChanged();
    }

    public static String getSelectedSoundState()
    {
        return selectedSoundState;
    }

    public static void setSelectedSoundState( String selectedSoundState )
    {
        SettingsConfig.selectedSoundState = selectedSoundState;
        settingsChanged();
    }

    public static int getSelectedLanguagePosition()
    {
        return selectedLanguagePosition;
    }

    public static void setSelectedLanguagePosition( int selectedLanguagePosition )
    {
        SettingsConfig.selectedLanguagePosition = selectedLanguagePosition;
        languageChanged();
    }

    public static int getSelectedScenePosition()
    {
        return selectedScenePosition;
    }

    public static void setSelectedScenePosition( int selectedScenePosition )
    {
        SettingsConfig.selectedScenePosition = selectedScenePosition;
        settingsChanged();
    }

    public static int getSelectedPopPosition()
    {
        return selectedPopPosition;
    }

    public static void setSelectedPopPosition( int selectedPopPosition )
    {
        SettingsConfig.selectedPopPosition = selectedPopPosition;
        settingsChanged();
    }

    public static int getSelectedMusicPosition()
    {
        return selectedMusicPosition;
    }

    public static void setSelectedMusicPosition( int selectedMusicPosition )
    {
        SettingsConfig.selectedMusicPosition = selectedMusicPosition;
        settingsChanged();
    }

    public static int getSelectedSoundPosition()
    {
        return selectedSoundPosition;
    }

    public static void setSelectedSoundPosition( int selectedSoundPosition )
    {
        SettingsConfig.selectedSoundPosition = selectedSoundPosition;
        settingsChanged();
    }

    public static String getBackGroundImagePath()
    {
        String backGroundImage = null;

        if ( Constants.GATEWAY_OF_INDIA.equalsIgnoreCase( getSelectedScene() ) )
        {
            backGroundImage = "gateway_of_india.png";
        }
        else if ( Constants.CHARMINAR.equalsIgnoreCase( getSelectedScene() ) )
        {
            backGroundImage = "charminar.png";
        }
        else
        {
            // Default
            backGroundImage = "india_gate.png";
        }

        return backGroundImage;
    }

    public static boolean isSoundEnabled()
    {
        boolean isSoundEnabled = false;

        if ( SoundState.ON.toString().equalsIgnoreCase( getSelectedSoundState() ) )
        {
            isSoundEnabled = true;
        }

        return isSoundEnabled;
    }

    public static boolean isMusicEnabled()
    {
        boolean isMusicEnabled = false;

        if ( MusicState.ON.toString().equalsIgnoreCase( getSelectedMusicState() ) )
        {
            isMusicEnabled = true;
        }

        return isMusicEnabled;
    }

    public static boolean isSettingsChanged()
    {
        return isSettingsChanged;
    }
    public static boolean isLanguageChanged()
    {
        return isLanguageChanged;
    }

    public static void setIsSettingsChanged( boolean isSettingsChanged )
    {
        SettingsConfig.isSettingsChanged = isSettingsChanged;
    }
    public static void setIsLanguageChanged( boolean isLanguageChanged )
    {
        SettingsConfig.isLanguageChanged = isLanguageChanged;
    }
    

    public static void settingsChanged()
    {
        setIsSettingsChanged( true );
    }
    public static void languageChanged()
    {
        setIsLanguageChanged( true);
    }

}
